﻿using System;
using System.Web.UI.WebControls;

namespace blackhouse.WebNemo.Web.Controls
{

    public class StringDisplayRecordValue : DisplayRecordValue
    {
        private Literal display;

        protected override void PopulateControl()
        {
            string text = "";
            if (base.column.DataType == typeof(byte))
            {
                text = base.record.GetBoolean(base.column.ColumnName) ? "Tak" : "Nie";
            }
            if (string.IsNullOrEmpty(text))
            {
                text = string.Format(base.column.FormattingValue, base.record[base.column.ColumnName]);
            }
            this.DisplayControl.Text = text;
        }

        private Literal DisplayControl
        {
            get
            {
                if (this.display == null)
                {
                    this.display = new Literal();
                    this.Controls.Add(this.display);
                }
                return this.display;
            }
        }
    }
}

